home *** CD-ROM | disk | FTP | other *** search
/ Super PC 34 / Super PC 34 (Shareware).iso / spc / UTIL / DJGPP2 / V2 / DJTST200.ZIP / tests / libc / dos / lfn.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-10-07  |  1.2 KB  |  36 lines

  1. /* Check the built in globbing (ie test *.c) and creation/accessed times */
  2.  
  3. #include <stdio.h>
  4. #include <sys/stat.h>
  5. #include <time.h>
  6.  
  7. int main(int argc, char **argv)
  8. {
  9.   if(argc == 1) {
  10.     printf("Usage: lfn [file list]\n");
  11.     printf("       the file list may contain wildcards\n");
  12.     exit(1);
  13.   }
  14.   argv++;
  15.   printf("Name                      Created Date      Modified Date     Accessed Date\n");
  16.   for(;*argv;argv++) {
  17.     struct stat stat_buf;
  18.     if(!stat(*argv, &stat_buf)) {
  19.       struct tm *tm1;
  20.       char ct[30],mt[30],at[30];
  21.       tm1 = localtime(&stat_buf.st_ctime);
  22.       sprintf(ct, "%02d/%02d/%2d %02d:%02d:%02d", tm1->tm_mon, tm1->tm_mday,
  23.         tm1->tm_year, tm1->tm_hour, tm1->tm_min, tm1->tm_sec);
  24.       tm1 = localtime(&stat_buf.st_mtime);
  25.       sprintf(mt, "%02d/%02d/%2d %02d:%02d:%02d", tm1->tm_mon, tm1->tm_mday,
  26.         tm1->tm_year, tm1->tm_hour, tm1->tm_min, tm1->tm_sec);
  27.       tm1 = localtime(&stat_buf.st_atime);
  28.       sprintf(at, "%02d/%02d/%2d %02d:%02d:%02d", tm1->tm_mon, tm1->tm_mday,
  29.         tm1->tm_year, tm1->tm_hour, tm1->tm_min, tm1->tm_sec);
  30.       printf("%-25s %s %s %s\n",*argv, ct, mt, at);
  31.     } else
  32.       printf("stat failed on %s\n",*argv);
  33.   }
  34.   return 0;
  35. }
  36.